using UnityEngine;

public class WizardWalkAudio : MonoBehaviour
{
	public AudioSource walkSource; // Drag your 'PlayerCharacter' Audio Source here

	private Rigidbody2D rb;

	void Start()
	{
		rb = GetComponent<Rigidbody2D>();
	}

	void Update()
	{
		// Only handles walking sound
		if (Mathf.Abs(rb.linearVelocity.x) > 0.1f && Mathf.Abs(rb.linearVelocity.y) < 0.01f)
		{
			if (!walkSource.isPlaying) walkSource.Play();
		}
		else
		{
			walkSource.Stop();
		}
	}
}